<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title th:title="${banner}">心灵短网址生成- 心灵短网址</title>
<meta name="keywords" content="">
<meta name="description" content="心灵短网址是一款能够在线批量生成短网址的心灵短网址生成器">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" rel="stylesheet"
	th:href="@{/frameindex/qingmeidwz.cn.css}" media="all">
<link rel="stylesheet" th:href="@{/frameindex/layer.css}"
	id="layuicss-layer">
<link rel="Shortcut Icon" th:href="@{${ico}}" type="image/x-icon" />
<style th:inline="css">
.banner{
	background: linear-gradient(rgba(23, 22, 23, 0.2), rgba(23, 22, 23, 0.5)), url([[${banner}]]) no-repeat fixed center center / cover;
    height: auto;
	
}

footer{
	font-size:14px;
	margin-top: auto;
	padding: 20px 0;
	width: 100%;
	color: #fff;
    background: #222 url([[${footer}]]) no-repeat fixed center center / cover;
    height: auto;
}

.panel {
    background: #fff;
    margin: 15px 0px 0px;
    padding: 15px 20px;
    overflow: hidden;
    display: none;
    border: 1px solid #c6cede;
}
.second_short_type{
	text-align: left;
}
.second_short_type label {
	float: left;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: normal;
    display: inline-block;
    margin-right: 20px;
    margin-top: 20px;
    margin-bottom: 10px;
}
</style>

</head>


<body style="zoom: 1;">

	<header id="header">
		<a th:href="@{/cn/index}" class="navbar-brand"> <img id="logo"
			class="flex-center" th:src="@{${logo}}" alt="心灵短网址">
		</a>
		<ul class="navbar-nav">

			<li class="fmenu "><a class="fmenu-a" th:href="@{/cn/index}">首页</a>

			</li>

			<li class="fmenu "><a class="fmenu-a" th:href="@{/cn/contact}">联系我们</a>

			</li>

			<li class="fmenu "><a class="fmenu-a" th:href="@{/}">登录</a></li>

			<li class="fmenu "><a class="fmenu-a" th:href="@{/register}">注册</a>

			</li>

		</ul>
	</header>
	<div class="banner">
		<div id="main">
			<div class="container-fluid" style="max-width: 900px">
				<div id="branding-primary" class="branding branding-lg center-block">
					<a th:href="@{/}" class="navbar-brand">
						<div id="logo-md">

							<img th:src="@{${logo}}" alt="心灵短网址" width="auto"
								class="center-block">
						</div>
					</a>
					<h2 id="slogan" class="text-center">心灵短网址在线生成</h2>
				</div>
				<div class="region region-content">
					<form class="form-keyword-search" onsubmit="return submit_form()">
						<ul class="nav nav-tabs">

							<li class="hidden-xs active"><a th:href="@{/cn/index}">心灵短网址</a></li>
							  <li class="hidden-xs" th:if="${openThird}"><a th:href="@{/cn/index2}" th:text="${thirdName}">第三方短网址</a></li> 
						</ul>
						<div class="tab-content form-wrapper"
							id="edit-keyword-search-form">
							<div id="form-keyword-search-wrap" class="row form-wrapper">
								<div class="col col-xs-12 col-md-10">
									<textarea class="form-text form-control required"
										placeholder="请输入需要缩短的链接，例如：http://www.baidu.com" type="text"
										id="text" name="text" value="" size="60"></textarea>
								</div>
								
								<div class="col col-xs-12 col-md-10 second_short_type">
									<label><input type="radio" name="open_type" value="FORWARD" th:checked="${defaultOpenWay=='FORWARD'}"/>直连</label>
									<label><input type="radio" name="open_type" value="FRAME" th:checked="${defaultOpenWay=='FRAME'}"/>框架</label>
								</div>
								<div class="col col-xs-12 col-md-10 second_short_type">
                                    <label><input type="checkbox" name="use_second_short" id="use_second_short" value="1"/>二次缩短</label>
                                </div>
								
								<div class="col col-xs-12 col-md-2">
									<button type="submit" id="btn-tcn" name="op"
										class="form-submit btn btn-primary">
										<span class="glyphicon">缩短</span>
									</button>
								</div>
							</div>
							<div id="wait" class='panel'>正在生成中，请稍等一会儿......</div>
							<div id="result_panel"></div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	<!--版块二-->
	<div class="section" id="section-scene">
		<div class="container-fluid">
			<div class="well well-lg">
				<h3>心灵短网址介绍</h3>
				<ul class="well-ul" id="caption">
				</ul>
				<div style="clear: both"></div>
			</div>
		</div>
	</div>

	<footer id="footer">
		<p class="text-inline" style="text-align: center;" th:utext="${footerText}">2019 - 2020
			心灵短网址 版权所有 盗版必究</p>
	</footer>

	<script th:src="@{/frameindex/hm.js}"></script>
	<script th:src="@{/frameindex/jquery.min.js}" type="text/javascript"
		charset="utf-8"></script>
	<script th:src="@{/frameindex/layer.js}" charset="utf-8"></script>
	<script th:inline="javascript"> 
	function NetPing(urlForValid) {
    	var r = true;
		if(urlForValid.indexOf('http')<0){
			r = false;
		}else{
			$.ajax({
				url: urlForValid,
				async: false,
				type: "GET",
				dataType: "jsonp",
				timeout:10000,
				complete: function(response, textStatus) {
					if(response.status == 200){
						r = true;
					}else{
						r = false;
					}
				}
			});
		}
		return r;
	}
	
		var ctx = [[@{/}]];
		
// 		console.log(ctx);
		function submit_form() {
			var url_longs = $("#text").val().split(/[\n,]/g);
			if (url_longs==null || url_longs.length==0) {
				layer.alert('请输入链接！');
				return false;
			}
			
			for(var i=0; i<url_longs.length; i++){
				var url_long = url_longs[i];
				if(!NetPing(url_long)){
					layer.alert('请输入正确的链接！');
					return false;
				}
			}
			
			$("#result_panel").html('').hide();
			
			var open_type = $("input[name='open_type']:checked").val();
			
			var use_second_short = $("input[name='use_second_short']:checked").val();
			if (typeof(use_second_short) == "undefined"){
				use_second_short = 0;
			}
// 			console.log("use_second_short："+use_second_short);
			$("#wait").show();
			var createUrl = ctx+'cn/create';
			$.ajax({
				url: createUrl,
				data: {
					'targetUrl' : url_longs,
					'openType': open_type,
					'useSecondShort': use_second_short
				},
				type: "POST",
				complete: function(response, textStatus) {
					$("#wait").hide();
					var html = "";
					var short_urls = response.responseJSON.data;
					for(var i=0; i<short_urls.length; i++){
						html += short_urls[i];
						if(i<short_urls.length-1){
							html += "<br/>";
						}
					}
					$('#result_panel').html(html);
					$("#result_panel").show();
					
				}
			});
			
			return false;
		}
		
		var captions = [[${captions}]];
		var captionHtml = "";
		for(var i=0; i<captions.length; i++){
			var con = captions[i];
			if('caption' == con.type){
				if(con.value!=null && con.value!=''){
					var strs = con.value.split("@||@");
					var title="";
					var content = "";
					if(strs.length==1){
						content = strs[0];
		    		}
		    		if(strs.length==2){
		    			title = strs[0];
		    			content = strs[1];
		    		}
					captionHtml+="<li><h4>"+title+"</h4> <br><p>"+content+"</p></li>";
				}
			}
		}
		$("#caption").html(captionHtml);
	</script>
</body>
</html>